<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>VIP管理系统-控制台</title>
		<meta name="keywords" content="song" />
		<meta name="description" content="song" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<!-- basic styles -->
		<link href="/Public/assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="/Public/assets/css/font-awesome.min.css" />


		<link rel="stylesheet" href="/Public/assets/css/family.css" />

		<link rel="stylesheet" href="/Public/assets/css/ace.min.css" />
		<link rel="stylesheet" href="/Public/assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="/Public/assets/css/ace-skins.min.css" />
	   <script src="/Public/assets/js/jquery-2.0.3.min.js"></script>
		<script src="/Public/admin/js/base.js"></script>
		
<style type="text/css" >
    .red{color: red;}
    body{ background: #fff;}
    .footer {
    width: 100%;
    height: 50px;
    position: fixed;
    bottom: 0;
   
    left: 0;
    line-height: 50px;
    text-align: right;
    text-align: right;
    border-top: solid 1px #eee;
    padding-right: 10px;
    z-index: 999999999999999;
}
</style>

	</head>
      <style type="text/css">
      .datalist_current_ahref{
	background: #6fb3e0!important;
		}
		.btn-light,.btn-info{
		   margin-right: 3px;
		}
</style>
<body>

    <!-- 弹窗插件 -->
    <!--弹窗插件-->
<link rel="stylesheet" href="/Public/artdialog/skins/blue.css" />
<script type="text/javascript" src="/Public/artdialog/artDialog.js"></script>
<script type="text/javascript" src="/Public/artdialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" src="/Public/artdialog/common_opfun.js"></script>

<!--提示插件-->
<link rel="stylesheet" href="/Public/notifit/notifIt.css" />
<script src="/Public/notifit/notifIt.js"></script>




 <div class="row"  >
        <div class="col-md-12" >
            <div class="block-web">
                <div class="header">
                    <h3 class="content-header"><?php if($is_add == 1): ?>编辑<?php else: ?>新增<?php endif; ?>权限组</h3>
                </div>
                <div class="porlets-content">
                    <form class="form-horizontal row-border vform_show" id="searchForm" action="#">
                        <table style="table-layout: fixed;width: 100%;">
                            <tr>
                                <td width="380px" style="vertical-align:top;">
                                    <input type="hidden" name="is_add" value="<?php echo ($is_add); ?>">
                                    <input type="hidden" name="id" value="<?php echo ($m['id']); ?>">
                                    <input type="hidden" name="rules" id="rules" value="<?php echo ($m['m_id']); ?>">
                                       <div class="form-group">
                                        <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 权限组名称 </label>
                                        <div class="col-sm-9">
                                            <input type="text" id="name" name="name" placeholder="请输入管理员名称" value="<?php echo ($m['name']); ?>"  onblur="check_old_pwd(this,'name')" class="col-xs-10">
                                                <span  style="display:none"> <i class="icon-ok green" ></i></span>
                                        </div>
                                    </div>




<!-- 
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">排序</label>
                                        <div class="col-sm-8">
                                            <input type="text" name="sort" class="form-control" value="<?php echo ((isset($m['sort']) && ($m['sort'] !== ""))?($m['sort']):'0'); ?>" datatype="n" nullmsg="请输入排序">
                                            <div class="Validform_checktip"></div>
                                        </div>

                                        <span class="red">*</span>

                                    </div><!--/form-group--> 


                                    <?php if($is_add == 1): ?><div class="form-group">
                                            <label class="col-sm-3 control-label">是否有效</label>
                                            <div class="col-sm-9">
                                                <label class="radio-inline">
                                                    <input type="radio"  <?php if($m['is_enable'] == 1): ?>checked<?php endif; ?> name="status" value="1" id="inlineradio1" >
                                                    <span class="custom-radio"></span> 启用 </label>
                                                <label class="radio-inline">
                                                    <input type="radio"  name="status"  <?php if($m['is_enable'] == 0): ?>checked<?php endif; ?>  value="0" id="inlineradio2">
                                                    <span class="custom-radio"></span> 禁止 </label>
                                            </div>
                                        </div>
                                        <?php else: ?>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">是否有效</label>
                                            <div class="col-sm-9">
                                                <label class="radio-inline">
                                                    <input type="radio"  checked name="status" value="1" id="inlineradio1" >
                                                    <span class="custom-radio"></span> 启用 </label>
                                                <label class="radio-inline">
                                                    <input type="radio"  name="status" value="0" id="inlineradio2">
                                                    <span class="custom-radio"></span> 禁止 </label>
                                            </div>
                                        </div><?php endif; ?>
<!-- 
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">描述</label>
                                        <div class="col-sm-9">
                                            <textarea name="remark" style="min-height: 75px;width: 100%;"><?php echo ($m['remark']); ?></textarea>
                                        </div>
                                        <div class="col-sm-1">
                                            <span class="red"></span>
                                        </div>
                                    </div> -->

                                </td>
                                <td style="padding-left: 50px;">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">权限：</label>
                                        <div class="col-sm-9">
                                            <div style="width: 100%;">
                                                <a href="javascript:;" onclick="checkAllTrue()" class="btn btn-success btn-xs">全选</a>&nbsp;
                                                <a href="javascript:;" onclick="checkAllFalse()" class="btn btn-success btn-xs">取消</a>&nbsp;
                                                <a href="javascript:;" onclick="expandAll()" class="btn btn-success btn-xs">展开</a>&nbsp;
                                                <a href="javascript:;" onclick="collapseAll()" class="btn btn-success btn-xs">折叠</a>&nbsp;
                                            </div>
                                            <div style="width: 100%;">
                                                <ul id="treeRule" class="ztree"></ul>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                        <div class="footer" >
                            <button class="btn btn-primary btn-success bt_submit" type="button" onclick="sub_quanxian()">提交</button>
                            <button class="btn btn-default bt_close" type="button" onclick="art.dialog.open.api.close();" >关闭</button>
                        </div>
                    </form>
                </div><!--/porlets-content-->
            </div><!--/block-web-->
        </div><!--/col-md-6-->

    </div>


<!--引入弹窗插件-->
    <div id="_show_public_loading_div" class="_show_public_loading_div" style=" position: fixed; left: 45%;top: 0px;height: 40px;
	    line-height: 40px;
	    width: 150px;
	    text-align: center;
	    background: #5CB85C;
	    border-bottom-left-radius: 8px;
	    border-bottom-right-radius: 8px;
	    border: 2px solid #F9F7F7;
	    border-top: none;
	    box-shadow: 0px 0px 10px #B1ADAD;
	    color: #FFF;z-index:99999999; ">
     <img src="/Public/Admin/images/icon32_loading_light218877.gif" style="width:20px;vertical-align: middle;">
        处理中...
    </div>

		<!-- basic scripts -->

		<!--[if !IE]> -->
			<script src="/Public/assets/js/jquery-2.0.3.min.js"></script>

		<!-- <![endif]-->

		<!--[if IE]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<![endif]-->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='/Public/assets/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='/Public/assets/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script>
		<script src="/Public/assets/js/bootstrap.min.js"></script>
		<script src="/Public/assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="assets/js/excanvas.min.js"></script>
		<![endif]-->
        <script src="/Public/assets/js/ace-extra.min.js"></script>
		<script src="/Public/assets/js/jquery-ui-1.10.3.custom.min.js"></script>
		<script src="/Public/assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="/Public/assets/js/jquery.slimscroll.min.js"></script>
		<script src="/Public/assets/js/jquery.easy-pie-chart.min.js"></script>
		<script src="/Public/assets/js/jquery.sparkline.min.js"></script>
		<script src="/Public/assets/js/flot/jquery.flot.min.js"></script>
		<script src="/Public/assets/js/flot/jquery.flot.pie.min.js"></script>
		<script src="/Public/assets/js/flot/jquery.flot.resize.min.js"></script>
		

		<!-- ace scripts -->

		<script src="/Public/assets/js/ace-elements.min.js"></script>
		<script src="/Public/assets/js/ace.min.js"></script>





			


		<!-- inline scripts related to this page -->






    <!-- 树 -->
        <link rel="stylesheet" href="/Public/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">

    <script type="text/javascript" src="/Public/ztree/js/jquery-migrate-1.2.1.js"></script>
    <script type="text/javascript" src="/Public/ztree/js/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="/Public/ztree/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script type="text/javascript">
      _hide_public_loading();
     var is_add = <?php echo ($is_add); ?>;
     var is_username = 0;
     var is_pwd = 0;
     var is_realname = 0;
     var is_mobile = 0;

     var setting = {
            view: {
                selectedMulti: false
            },
            check: {
                enable: true
            },
            data: {
                simpleData: {
                    enable: true
                }
            }
        };
        var treeObj;
        function createTree() {
            $.post("<?php echo U('Nav/menu_ajax',array('id'=>$id));?>",function(resultobj){
                treeObj= $.fn.zTree.init($("#treeRule"), setting, resultobj);
                 treeObj.expandAll(true);
            });



        }

        $(function(){
            createTree();
        });
        function checkAllTrue(){
            treeObj.checkAllNodes(true);
        }
        function checkAllFalse(){
            treeObj.checkAllNodes(false);
        }
        function expandAll(){
            treeObj.expandAll(true);
        }
        function collapseAll(){
            treeObj.expandAll(false);
        }
    // $(function(){
    //     goSearch("#searchForm","order_list_item_content");
    // });
  function check_old_pwd(_this,type){
      //验证密码
      if(type =="name"){
        var username = $(_this).val();
        if(username == "" || username.length<2 || username.length >16){
             $(_this).parent().children('span').show();
             $(_this).parent().children('span').html('<i class="icon-remove red"></i>');
             return false; 
         }else{
             $(_this).parent().children('span').html('<i class="icon-ok green"></i>');
         }
      }

  }


function  sub_quanxian(){
             huoquanxian();
            // console.log($('#searchForm').serialize());
            showvfmsg("-1", '提交中，请稍后...', 999999); 
             var url="<?php echo U('Nav/add_nav_group');?>";
                $.ajax({
                    'url':url,
                    'data':$('#searchForm').serialize(),
                    'dataType':'json',
                    'type':'post',
                    beforeSend:function(){
                         $("#submit").attr("disabled",'disabled');
                         $("#submit").html("提交中...");
                         $(".bt_submit").attr("disabled", 'disabled');
                         $(".bt_submit").html("提交中...");
                    },
                    success:function(data){
                            $("#submit").removeAttr('disabled');
                            $("#submit").html("提交");
                            $(".bt_submit").removeAttr('disabled');
                            $(".bt_submit").html("提交");
                            var retstatus = data.state == 1 ? "1" : "0";
                            showvfmsg(retstatus, data.msg, 1900);
                            if(retstatus ==1){
                               setTimeout(function(){
                                window.parent.load();
                                art.dialog.open.api.close();

                                // self.opener.location.reload(); 
                            },1000)

                            }
                        // goSearch("#searchForm","order_list_item_content");

                        //_reload_currentpage_datalist('order_list_item_content');
                        // goSearch("#searchForm","order_list_item_content");


                    },error:function(){
                        showvfmsg('error','请求服务器失败',2000);
                    },complete:function(){
                            $("#submit").removeAttr('disabled');
                            $("#submit").html("提交");
                            $(".bt_submit").removeAttr( 'disabled');
                            $(".bt_submit").html("提交");
                    }
      })
       
}

    // function load(){
    //     goSearch("#searchForm","order_list_item_content");
    // }

function huoquanxian(){
        var nodes=treeObj.getCheckedNodes(true);
        var newArrays=new Array();
        for(var  i=0;i<nodes.length;i++){
            newArrays.push(nodes[i].id);
        }
        // console.info(newArrays);
        $("#rules").val(newArrays.join(","));
    }


    </script>

</body>
</html>